import open3d as o3d
import numpy as np
pcd = o3d.io.read_point_cloud("./data/dorm.txt", format='xyz')
print(pcd)#输出点云点的个数
print(np.asarray(pcd.points))#输出点的三维坐标
print('给所有的点上一个统一的颜色，颜色是在RGB空间得[0，1]范围内得值')
mesh_frame = o3d.geometry.TriangleMesh.create_coordinate_frame(size=0.1, origin=[0, 0, 0])
# pcd.compute_vertex_normals()
# pcd.paint_uniform_color([1, 0, 0])
o3d.io.write_point_cloud("copy_of_fragment.pcd", pcd)
# o3d.visualization.draw_geometries([pcd,mesh_frame])
o3d.visualization.draw_geometries([pcd])
# points_data = np.loadtxt("./data/dorm.txt", delimiter=",", dtype=np.float32)
# print(points_data)


# ff = open('data/verify/rawdata2.txt', 'w')  #打开一个文件，可写模式
# with open('./data/rawdata.txt','r') as f:  #打开一个文件只读模式
#     line = f.readlines()
#     # i = 0
#     for line_list in line:
#         line_new =line_list.replace('\n','')  #将换行符替换为空('')
#         # b = str(label) #主要是这一步 将之前列表数据转为str才能加入列表
#         line_new = line_new +',\n'
#         # i += 1
#         print(line_new)
#         ff.write(line_new) #写入一个新文件中



# f=open("./data/motorangle.txt")
# a=f.readlines()
# # for b in a:
# #     print(int(b.strip("\n")))
# print(len(a))
# print(a[24016])





# file = open("./data/dorm.txt", 'w')
# file.write("a\n")
#
# # while True:
# #     file.write('123456789945421541545\n')
#     # file.write('123456789945421541545\n')
# file.close()
# a=[[1,2,3],[2,3,4]]
# f=open("./data/tes.txt","w")
# f.writelines(a)
# f.write("\n")
# import numpy as np
# a = [[1,2],[3,4]]
# print(np.array(a).shape)
# a=[]


# print(np.array(b).shape)
# print(np.array(b[0]).shape)

# a.append(b)
# print(np.array(a).shape)
# print(type(a),len(a))
# print(list(a[0]),type(list(a[0])))
# for i in range(len(a)):
#     print(a[i],type(a[i]))
# print(a)
# for i in f:
#     print(i[])
#     print(i,type(i))
    # print(list[i])
# import ast
# response="[a,b,c]"
# # res=response.strip('[')
# # res=res.strip(']')
# # res=res.split(',')
# print(ast.literal_eval(response))